/*
 * Copyright © 2009 Perseus Project - Tufts University <http://www.perseus.tufts.edu>
 *
 * This file is part of UniCollatorPerseus.
 *
 * OcroPerseus is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * OcroPerseus is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with OcroPerseus.  If not, see <http://www.gnu.org/licenses/>.
 */

package eu.himeros.ocr.image;

import eu.himeros.util.IoManager;
import java.io.BufferedReader;
import java.io.BufferedWriter;

/**
 * Strips out lines preceded by # and write them in a .box file.
 * Works with ImgMaker
 *
 * @author Federico Boschetti <federico.boschetti.73@gmail.com>
 */
public class BoxWriter {
    BufferedReader br=null;
    BufferedWriter bw=null;
    String fileName=null;

    /**
     *
     */
    public BoxWriter(){}

    /**
     *
     * @param fileName
     */
    public BoxWriter(String fileName){
        this.fileName=fileName;
        init();
    }

    /**
     *
     */
    public void init(){
        String line=null;
        try{
            br=IoManager.getReader(fileName+".gbx");
            bw=IoManager.getWriter(fileName+".box");
            while((line=br.readLine())!=null){
                if(line.length()>0&&line.startsWith("#")){
                    line=br.readLine();
                    bw.write(line);bw.newLine();
                }
                
            }
            bw.close();
        }catch(Exception e){e.printStackTrace();}
    }

    /**
     *
     * @param args
     */
    public static void main(String[] args){
        BoxWriter bxw=new BoxWriter(args[0]);
    }

}
